<!--废弃页面，供参考-->
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>添加会员-WeAdmin 1.0</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../static/css/font.css">
		<link rel="stylesheet" href="../../static/css/weadmin.css">
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
	      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
	      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
	    <![endif]-->
	</head>

	<body>
		<div class="weadmin-body">
			<form class="layui-form">
				<div class="layui-form-item">
					<label for="L_username" class="layui-form-label">
		                <span class="we-red">*</span>登录名
		            </label>
					<div class="layui-input-inline">
						<input type="text" id="L_username" name="username" lay-verify="required|nikename" autocomplete="off" class="layui-input">
					</div>
					<div class="layui-form-mid layui-word-aux">
						请设置至少5个字符，将会成为您唯一的登录名
					</div>
				</div>
				<div class="layui-form-item">
				    <label for="L_sex" class="layui-form-label">性别</label>
				    <div class="layui-input-block" id="L_sex">
				      <input type="radio" name="sex" value="男" title="男" checked>
				      <input type="radio" name="sex" value="女" title="女">
				      <input type="radio" name="sex" value="未知" title="未知">
				    </div>
				</div>

				<div class="layui-form-item">
					<label for="L_email" class="layui-form-label">
		                <span class="we-red">*</span>手机
		            </label>
					<div class="layui-input-inline">
						<input type="text" id="L_phone" name="phone" lay-verify="required|phone" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label for="L_email" class="layui-form-label">
		                <span class="we-red">*</span>邮箱
		            </label>
					<div class="layui-input-inline">
						<input type="text" id="L_email" name="email" lay-verify="email" autocomplete="off" class="layui-input">
					</div>

				</div>
				<div class="layui-form-item">
					<label for="L_pass" class="layui-form-label">
                  <span class="we-red">*</span>密码
              </label>
					<div class="layui-input-inline">
						<input type="password" id="L_pass" name="pass" required="" lay-verify="pass" autocomplete="off" class="layui-input">
					</div>
					<div class="layui-form-mid layui-word-aux">
						6到16个字符
					</div>
				</div>
				<div class="layui-form-item">
					<label for="L_repass" class="layui-form-label">
                  <span class="we-red">*</span>确认密码
              </label>
					<div class="layui-input-inline">
						<input type="password" id="L_repass" name="repass" required="" lay-verify="repass" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label for="L_repass" class="layui-form-label">
              </label>
					<button class="layui-btn" lay-filter="add" lay-submit="">增加</button>
				</div>
			</form>
		</div>
		<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
		<script src="../../lib/layui/layui.js" charset="utf-8"></script>
		<script type="text/javascript" src="../../static/js/admin.js"></script>
		<script>
			layui.use(['form', 'layer'], function() {
				$ = layui.jquery;
				var form = layui.form,
					layer = layui.layer;

				//自定义验证规则
				form.verify({
					nikename: function(value) {
						if(value.length < 5) {
							return '昵称至少得5个字符啊';
						}
					},
					pass: [/(.+){6,12}$/, '密码必须6到12位'],
					repass: function(value) {
						if($('#L_pass').val() != $('#L_repass').val()) {
							return '两次密码不一致';
						}
					}
				});

				//监听提交
				form.on('submit(add)', function(data) {
					console.log(data.field);
					var f = data.field;
					console.log(f.username);
					console.log(f.sex);
					var sex = $('input:radio[name="sex"]:checked').val();
					//发异步，把数据提交给php
					layer.alert("增加成功", {
						icon: 6
					}, function() {
						// 获得frame索引
						var index = parent.layer.getFrameIndex(window.name);
//						parent.location.reload();					
						parent.$('input[name="username"]').val(f.username);
						parent.$('input[name="sex"]').val(f.sex);
						parent.$('input[name="email"]').val(f.email);
						parent.$('input[name="phone"]').val(f.phone);
						parent.$('input[name="pass"]').val(f.pass);
						
//  					var _len = parent.$('#memberList tr').length;
//  					alert(_len);
//						parent.$('#memberList').append(						
//							'<tr data-id="' + _len + '">' +
//								'<td>'+
//									'<div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id="' + _len + '"><i class="layui-icon">&#xe605;</i></div>'+
//								'</td>'+
//								'<td>' + _len + '</td>'+
//								'<td>'+f.username+'</td>'+
//								'<td>'+f.sex+'</td>'+
//								'<td>'+f.phone+'</td>'+
//								'<td>'+f.email+'</td>'+
//								'<td>北京市西城区</td>'+
//								'<td>2018-01-01 11:11:42</td>'+
//								'<td class="td-status"><span class="layui-btn layui-btn-normal layui-btn-xs">已启用</span></td>'+
//								'<td class="td-manage">'+
//									'<a onclick="member_stop(this,\'10001\')" href="javascript:;" title="启用"><i class="layui-icon">&#xe601;</i></a>'+
//									'<a title="编辑" onclick="WeAdminShow(\'编辑\',\'./edit.html\',600,400)" href="javascript:;"><i class="layui-icon">&#xe642;</i></a>'+
//									'<a onclick="WeAdminShow(\'修改密码\',\'./password.html\',600,400)" title="修改密码" href="javascript:;"><i class="layui-icon">&#xe631;</i></a>'+
//									'<a title="删除" onclick="member_del(this,\'要删除的id\')" href="javascript:;"><i class="layui-icon">&#xe640;</i></a>'+
//								'</td>'+
//							'</tr>'	
//						);
						parent.addMember();
						//关闭当前frame
						parent.layer.close(index);
					});
					return false;
				});

			});
		</script>
	</body>

</html>